#pragma once

#include "PenteVector.h"
#include "PenteBoardNode.h"
#include "PenteBoard.h"
#include "screen.h"

class PenteVector;
class PenteBoardNode;
class PenteBoard;


class Cursor
{
private:
	//cursor logical position
	PenteVector cursorPos;
	
	//object pointers
	PenteBoard* pGameBoard;
	PenteBoardNode* pBoardNode;

public:
	Cursor( PenteBoard* q ): cursorPos(0,0)
	{
		pGameBoard = q;
		pBoardNode = NULL;
	}
	~Cursor(){}

	void setXY( int a_x, int a_y )
	{
		cursorPos.setXY(a_x, a_y);
	}
	void setX( int a_x ){ cursorPos.setX(a_x); }
	void setY( int a_y ){ cursorPos.setY(a_y); }
	int getX(){ return cursorPos.getX(); }
	int getY(){ return cursorPos.getY(); }

	bool addToBoard( PenteBoard * );
	void moveCursor( int );

	void drawCursor( Screen * );

/*	//cursor movement checks 
	bool chkCursorLeft()		//Replaced with moveCursor() -Kaero
	{
		int temp = RowCol( cursorPos.getX(), cursorPos.getY() - 1 );
		if( cursorPos.getY() - 1 >= 0  )
			return true;
		else
			return false;
	}
	bool chkCursorRight()
	{
		int temp = RowCol( cursorPos.getX(), cursorPos.getY() + 1 );
		if( cursorPos.getY() + 1 < (BOARD_SIZE - 1)  )
			return true;
		else
			return false;
	}
	bool chkCursorUp()
	{
		int temp = RowCol( cursorPos.getX() - 1, cursorPos.getY() );
		if( cursorPos.getX() - 1 >= 0 )
			return true;
		else
			return false;
	}
	bool chkCursorDown()
	{
		int temp = RowCol( cursorPos.getX() + 1, cursorPos.getY() );
		if( cursorPos.getX() + 1 < (BOARD_SIZE - 1) )
			return true;
		else
			return false;
	}

	//cursor movement
	void moveCursorLeft()
	{
		if( cursorPos.getY() - 1 >= 0   )
			cursorPos.setY( cursorPos.getY() - 1 );
		else
			cursorPos.setY( BOARD_SIZE - 1 );
	}
	void moveCursorRight()
	{
		if( cursorPos.getY() + 1 < (BOARD_SIZE - 1) )
			cursorPos.setY( cursorPos.getY() + 1 );
		else
			cursorPos.setY( 0 );
	}
	void moveCursorUp()
	{
		if( cursorPos.getX() - 1 >= 0 )
			cursorPos.setX( cursorPos.getX() - 1 );
		else
			cursorPos.setX( BOARD_SIZE - 1 );
	}
	void moveCursorDown()
	{
		if( cursorPos.getX() + 1 < (BOARD_SIZE - 1) )
			cursorPos.setX( cursorPos.getX() + 1 );
		else
			cursorPos.setX( 0 );
	}*/

	//misc. functions
	int getRow( int x ){ return x / BOARD_SIZE; }
	int getCol( int y ){ return y % BOARD_SIZE; }
	int RowCol( int x, int y ){ return x * BOARD_SIZE + y; }
};